package com.ahmedmisbah.andgenplus.restgenerator.beans;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RESTWebServiceDescriptor {

	public enum RESTWebServiceType {
		GET, POST, PUT, DELETE
	}

	public enum URLFormat {
		AND, SLASH
	}
	
	public static final String AND_VALUE="operationName?param1=1&param2=2";
	public static final String SLASH_VALUE="operationName/1/2";

	private String webServiceName;
	private String operationName;
	private String packagePath;
	private String webServiceURL;
	private List<Parameter> parameters;
	private String json;
	private RESTWebServiceType type;
	private URLFormat urlFormat;

	private Map<String, Mapper> mappers = new HashMap<String, Mapper>();

	public Map<String, Mapper> getMappers() {
		return mappers;
	}

	public String getWebServiceURL() {
		return webServiceURL;
	}

	public void setWebServiceURL(String webServiceURL) {
		this.webServiceURL = webServiceURL;
	}

	public List<Parameter> getParameters() {
		return parameters;
	}

	public void setParameters(List<Parameter> parameters) {
		this.parameters = parameters;
	}

	public String getJson() {
		return json;
	}

	public void setJson(String json) {
		this.json = json;
	}

	public String getWebServiceName() {
		return webServiceName;
	}

	public void setWebServiceName(String webServiceName) {
		this.webServiceName = webServiceName;
	}

	public String getPackagePath() {
		return packagePath;
	}

	public void setPackagePath(String packagePath) {
		this.packagePath = packagePath;
	}

	public RESTWebServiceType getType() {
		return type;
	}

	public void setType(String typeString) {

		if (typeString.equalsIgnoreCase("get")) {
			setType(RESTWebServiceType.GET);
		} else if (typeString.equalsIgnoreCase("post")) {
			setType(RESTWebServiceType.POST);
		} else if (typeString.equalsIgnoreCase("put")) {
			setType(RESTWebServiceType.PUT);
		} else if (typeString.equalsIgnoreCase("delete")) {
			setType(RESTWebServiceType.DELETE);
		}

	}

	public void setType(RESTWebServiceType type) {
		this.type = type;
	}

	public URLFormat getUrlFormat() {
		return urlFormat;
	}
	
	public void setUrlFormat(String urlFormatString) {
		if (urlFormatString.equalsIgnoreCase(AND_VALUE)) {
			setUrlFormat(URLFormat.AND);
		} else if (urlFormatString.equalsIgnoreCase(SLASH_VALUE)) {
			setUrlFormat(URLFormat.SLASH);
		}
	}

	public void setUrlFormat(URLFormat urlFormat) {
		this.urlFormat = urlFormat;
	}

	public String getOperationName() {
		return operationName;
	}

	public void setOperationName(String operationName) {
		this.operationName = operationName;
	}

}
